home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Atari Mega Archive 2
/
Atari Mega Archive CD - Volume 2.iso
/
8bit
/
archiver
/
binhex.bas
< prev
next >
Wrap
BASIC Source File
|
1995-04-22
|
2KB
|
49 lines
1 REM BINHEX 1.0, OCTOBER 1984
2 REM -- BY DAN FLEYSHER --
3 REM (FLEYSHER.WBST@XEROX)
4 REM THIS BASIC PROGRAM CONVERTS A
5 REM BINARY DISK FILE TO THE EQUIV-
6 REM VALENT TEXT FILE CONTAINING
7 REM HEXIDECIMAL CHARACTERS. THIS
8 REM FILE IS SUITABLE FOR LONG
9 REM DISTANCE (MODEM) TRANSMISSION,
10 REM AND CONTAINS A FULL CHECKSUM.
11 REM A COMPANION PROGRAM, HEXBIN,
12 REM CONVERTS THE HEX FILE BACK TO
13 REM THE ORIGINAL BINARY FORMAT.
14 REM
20 DIM FILEIN$(15),FILEOUT$(15),BYTE$(2)
30 BUFSIZ=37:DIM BUF$(BUFSIZ),HEX$(16)
40 HEX$="0123456789ABCDEF"
50 ? "} BINHEX 1.0":? :?
60 TRAP 60:? "INPUT FILENAME";:INPUT FILEOUT$
70 GOSUB 1000:FILEIN$=FILEOUT$:?
80 TRAP 80:? "OUTPUT FILENAME";:INPUT FILEOUT$
90 IF FILEOUT$<>"" THEN 110
100 FILEOUT$="D:HEXFILE.TXT":? " ";FILEOUT$:GOTO 120
110 GOSUB 1000:?
120 TRAP 40000:SUM=0
130 OPEN #4,4,0,FILEIN$:OPEN #5,8,0,FILEOUT$
140 PRINT #5:PRINT #5;".START."
150 BUF$=""
160 TRAP 300:FOR I=1 TO INT(BUFSIZ/2)
170 GET #4,BYTE:SUM=SUM+BYTE
180 NIBBLE=INT(BYTE/16)
190 INDEX=1+NIBBLE
200 BYTE$(1)=HEX$(INDEX,INDEX)
210 INDEX=1+BYTE-(16*NIBBLE)
220 BYTE$(2)=HEX$(INDEX,INDEX)
230 BUF$(LEN(BUF$)+1)=BYTE$
240 NEXT I:TRAP 40000
250 ? BUF$:PRINT #5;BUF$:GOTO 150
300 ? BUF$:PRINT #5;BUF$:POP
310 ? "CHECK SUM = ";SUM
320 PRINT #5;".STOP.";SUM
330 CLOSE #4:CLOSE #5
340 END
1000 IF LEN(FILEOUT$)<3 THEN GOTO 1040
1010 IF FILEOUT$(1,2)="D:" THEN RETURN
1020 IF LEN(FILEOUT$)<4 THEN GOTO 1040
1030 IF FILEOUT$(1,1)="D" AND FILEOUT$(3,3)=":" THEN RETURN
1040 BUF$=FILEOUT$:FILEOUT$="D:":FILEOUT$(3)=BUF$:RETURN